<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib tagdir="/WEB-INF/tags/busterminal/" prefix="bt"%>
<%@taglib uri="/WEB-INF/tags/tlds/Functions.tld" prefix="f"%>

<bt:IncludedFiles />
<c:set var="user" scope="session" value="${user}" />
<table class="table table-striped table-bordered table-condensed">
    <caption>Route list</caption>
    <thead>
        <tr>
            <th align="center">Route number</th>
            <th align="center">Route name</th>
            <th align="center">Start point name</th>
            <th align="center">End point name</th>
            <th align="center">Intermediate stopping points list</th>
            <th align="center">Route type</th>
            <c:if test="${f:isActionAllowed('route.edit', user.getRole())}">
                <th>&nbsp;</th>
            </c:if>
            <c:if test="${f:isActionAllowed('route.delete', user.getRole())}">
                <th>&nbsp;</th>
            </c:if>
        </tr>
    </thead>
    <tbody>
        <c:set var="route" scope="page" value="${route}" /> 

        <tr>                
            <td><c:out value="${route.getRouteNumber()}" /></td>
            <td><c:out value="${route.getRouteName()}" /></td>                
            <td><c:out value="${route.getStartPoint().getStoppingPointName()}" /></td>                
            <td><c:out value="${route.getEndPoint().getStoppingPointName()}" /></td>
            <td><c:out value="${route.getIntermediateStoppingPointsString()}" />&nbsp;</td>
            <td><c:out value="${route.getRouteType()}" /></td>

            <c:if test="${f:isActionAllowed('route.edit', user.getRole())}">
                <c:url var="editURL" value="MainServlet">
                    <c:param name="action" value="route.edit" />
                    <c:param name="id" value="${route.getId()}" />
                </c:url>
                <td nowrap width="48"><a class="btn btn-mini" href="${editURL}" id="show-edit-form" data-toggle="tab"><i class="icon-pencil icon-white"></i>&nbsp;Edit</a></td>
            </c:if>

            <c:if test="${f:isActionAllowed('route.delete', user.getRole())}">
                <c:url var="deleteURL" value="MainServlet">
                    <c:param name="action" value="route.delete" />
                    <c:param name="id" value="${route.getId()}" />
                </c:url>
                <td nowrap width="62"><a class="btn btn-mini" id="show-delete-dialog" data-target="#delete-modal-window" data-toggle="modal" data-link="${deleteURL}" data-name="${route.getRouteNumber()}; ${route.getRouteName()}; ${route.getStartPoint().getStoppingPointName()}; ${route.getEndPoint().getStoppingPointName()} ${route.getIntermediateStoppingPointsString()}; ${route.getRouteType()}"><i class="icon-trash icon-white"></i>&nbsp;Delete</a></td>
            </c:if>    
        </tr>
    </tbody>
</table>
<a class="btn btn-mini" href="MainServlet?action=main"><i icon-arrow-left class="icon-arrow-left icon-white"></i>&nbsp;Back</a>
<bt:DeleteDialog entity="route" />